﻿using System;

namespace VPLink2014.Data
{
    public class VPLinkLogConnection : IDisposable
    {
        private VPLinkLogEntities _vplinkEntities;

        public VPLinkLogEntities VplinkEntities
        {
            get { return _vplinkEntities; }
        }

        public VPLinkLogConnection()
        {
            _vplinkEntities = new VPLinkLogEntities();
            _vplinkEntities.Configuration.ProxyCreationEnabled = false;
        }

        #region IDisposable Members

        public void Dispose()
        {
            if (_vplinkEntities == null)
            {
                return;
            }
            try
            {
                _vplinkEntities.SaveChanges();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                _vplinkEntities.Dispose();
                _vplinkEntities = null;
            }
        }

        #endregion
    }
}
